#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 100005;
int n, m;
double s;
int S[N];
int num_e;
struct node {
	int b, e;
	double cost;
}d[N];
bool cmp (node x, node y) {
	return x.cost < y.cost;
}
int getf (int x) {
	if (x == S[x]) {
		return x;
	}
	return S[x] = getf(S[x]);
}
void merge (int x, int y) {
	int u = getf(x), v = getf(y);
	if (u != v) {
		S[y] = u;
		S[v] = u;
	}
}
double kruskal (int y) {
	double ans = 0.0;
	sort (d + 1, d + y + 1, cmp);
	for (int i = 1; i <= y; i++) {
		if (getf(d[i].b) == getf(d[i].e)) {
			continue;
		} 
		merge (d[i].b, d[i].e);
		num_e++;
		ans += d[i].cost;
		if (num_e == n - 1) {
			return ans;
		}
	}
	return -1;
}
int main() {
	scanf ("%lf%d", &s, &n);
	int u, v;
	double r;
	while (~scanf ("%d", &u)) {
		scanf ("%d%lf", &v, &r);
		m++;
		d[m].b = u;
		d[m].e = v;
		d[m].cost = r;
	}
	for (int i = 1; i <= n; i++) {
		S[i] = i;
	}
	double ans = kruskal(m);
	if (s >= ans && ans > 0) {
		printf ("Need %.2lf miles of cable\n", ans); 
	} else {
		printf ("Impossible\n");
	}
	return 0;
}